/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.yandex.sumofseries.utilconcurrent;

import static java.lang.Math.cos;
import static java.lang.Math.sin;
import java.util.concurrent.Callable;

/**
 *
 * @author Neophron
 */
public class Calc implements Callable<Double> {

    private final double from, to;

    Calc(double from, double to) {
        this.from = from;
        this.to = to;
    }

    @Override
    public Double call() {
        double result = 0;
        double x = from;
        while (x <= to) {
            result += sin(x) * cos(x);
            x += Sum.STEP;
        }
        return result;
    }

}
